<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>设备管理</title>
<link rel="stylesheet" href="/scriptZIP/layui.min.css">
	<link rel="stylesheet" href="../css/common2.css">
	<link rel="stylesheet" href="../css/layui.css" />
	<style>
		.layui-row {
			margin-top: 50px;
		}

		.offer {
			width: 90px;
			height: 35px;
			color: white;
			text-align: center;
			line-height: 35px;
			font-size: 16px;
			border-radius: 4px;
		}

		.return {
			width: 80px;
			height: 35px;
			color: white;
			text-align: center;
			line-height: 35px;
			margin-top: -35px;
			margin-left: 130px;
			font-size: 16px;
			border-radius: 4px;
		}

		#portrait {
			width: 100px;
			height: 100px;
		}

		.img-wrap {
			display: inline-block;
			position: relative;
		}

		.remove {
			position: absolute;
			top: 3px;
			right: 3px;
		}
	</style>
</head>

<body>
	<div class="layui-row" id="vue-root">
		<div></div>
		<div class="layui-col-md6 layui-col-md-offset3">

			<div class="layui-form-item">
				<label class="layui-form-label">设备位置</label>
				<div class="layui-input-block">
					<input name="deviceName" v-validate="'required'" autocomplete="off" placeholder="请输入设备位置"
						class="layui-input name" v-model="item.name">
					<div class="checkout_state" v-text="err('deviceName')"></div>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">设备编码</label>
				<div class="layui-input-block">
					<input name="deviceCode" v-validate="'required'" autocomplete="off" placeholder="请输入设备编码"
						class="layui-input tag" v-model="item.code">
					<div class="checkout_state" v-text="err('deviceCode')"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<div class="offer" @click="submit">立即提交</div>
					<div class="return" onclick="history.back()">取消</div>
				</div>
			</div>
		</div>
	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	
	
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/item.js"></script>

	<script>
		var app = new Vue(merge({
			data: {
				item: {
					schoolId: top_params().id,
					type: 2
				},
				url: '/pc/device'
			},
			methods: {
				upload: function () {
					axios.post('/pc/upload/device?schoolId=' + this.item.schoolId,
						new FormData(this.$refs.form)).then(function (res) {
							this.item.pic = res.data.data;
						}.bind(this));
				},
				delPic: function () {
					this.item.pic = '';
				}
			},
			computed: {
				img: function () {
					if (!this.item.pic) return '/image/upload.png';
					return '/static/' + this.item.schoolId + '/device/' + this.item.pic;
				}
			}
		}));

	</script>
</body>

</html>